
<script>
	var treeDom = $('#id_tree');
	$(function () {
		$('.left-tree-div').height($(window).height() - 200);
		
		$.ajax({
			type: "post",
			url: "/api/inter/menu/tree",
			data: {},
			dataType: "json",
			success: function (result) {
				treeDom.treeview({
					selectedIcon : 'glyphicon glyphicon-stop',
					data: result.data,         // 数据源
					levels : 3,  //设置继承树默认展开的级别
					showIcon : false,
					showCheckbox : false,
					showTags: false, //是否在每个节点右边显示tags标签。tag值必须在每个列表树的data结构中给出
					multiSelect : false,
					onNodeSelected : function (event, data) {
						if (data.type == 'module') {
							obj_.table.param.moduleId = data.id;
							obj_.table.param.menuPid = '';
							obj_.table.table.bootstrapTable("refreshOptions", {pageNumber: 1});
							return;
						}
						
						if (data.type == 'menu' && data.menuLev == 2) {
							return;
						}
						
						if (data.type == 'menu' && data.menuLev == 1) {
							obj_.table.param.moduleId = '';
							obj_.table.param.menuPid = data.id;
							obj_.table.param.orderby = 'menu_sort_no';
							obj_.table.param.sorttype = 'asc';
							obj_.table.table.bootstrapTable("refreshOptions", {pageNumber: 1});
							return;
						}
					}
				});
			},
			error: function () {
			    alert("加载失败！")
			}
	   });

        // 一键添加字段
        bindClickCommitAjax(
       		obj_.formSearch.find('.btn-add-cols'),
       		obj_.table.table,
       		"确定添加",
       		"添加成功后可在字段管理查看",
       		"/api/inter/[[${menu.menuTable}]]/addCols",
       		[{fieldName : '[[${menu.menuPkName}]]'}]
     	);
	});
</script>